//路由表
const routes = [
  {
    path: '/index', //路由地址
    name: 'index',
    meta: { title:'index' }, //路由元信息
    component: () => import('../views/Index.vue'), //路由地址对应的组件
    children:[ //二级路由
      {
        path: '/index/home', //路由地址
        name: 'home',
        meta: { title:'首页' },
        component: () => import('../views/Index/Home.vue'), //路由地址对应的组件
        /* beforeEnter(to,from,next){ //路由独享的守卫函数
          console.log('beforeEnter');
          next();
        } */
      },
      {
        path: '/index/tuan', //路由地址
        name: 'tuan',
        meta: { title:'爆爆团' },
        component: () => import('../views/Index/Tuan.vue'), //路由地址对应的组件
        children:[ //三级路由
          {
            path: '/index/tuan/tuan0', //路由地址
            name: 'tuan0',
            meta: { title:'正在抢购' },
            component: () => import('../views/Index/Tuan/Tuan0.vue'), //路由地址对应的组件
          },
          {
            path: '/index/tuan/tuan1', //路由地址
            name: 'tuan1',
            meta: { title:'上新预告' },
            component: () => import('../views/Index/Tuan/Tuan1.vue'), //路由地址对应的组件
          },
        ]
      },
      {
        path: '/index/order', //路由地址
        name: 'order',
        meta: { title:'订单' },
        component: () => import('../views/Index/Order'), //路由地址对应的组件
      },
      {
        path: '/index/mine', //路由地址
        name: 'mine',
        meta: { title:'我的' },
        component: () => import('../views/Index/Mine.vue'), //路由地址对应的组件
      },
      {
        path: '/index',
        redirect:'/index/home' //路由重定向
      },
      { //404 路由
        path: '*', // * 表示 匹配所有路由地址
        component: () => import('../views/NotFound.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    meta: { title:'登陆' },
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/register',
    name: 'register',
    meta: { title:'注册' },
    component: () => import('../views/Register.vue')
  },
  {
    path: '/collect',
    name: 'collect',
    meta: { title:'我的收藏' },
    component: () => import('../views/Collect.vue')
  },
  {
    path: '/detail/:id',
    name: 'detail',
    meta: { title:'店铺详情' },
    component: () => import('../views/Detail.vue')
  },
  {
    path: '/search',
    name: 'search',
    meta: { title:'我的收藏' },
    component: () => import('../views/Search.vue')
  },
  { //重定向路由
    path: '/',
    redirect: '/index' //路由重定向
  },
  { //404 路由
    path: '*', // * 表示 匹配所有路由地址
    component: () => import('../views/NotFound.vue')
  }
]

export default routes;